﻿using System.Linq;
using EBE.COM.Core.Interfaces;
using NUnit.Framework;

namespace EBE.COM.Core.Test.Categories
{
  [TestFixture]
  public class TestCategories
  {
    private ICategoryRepository _repository;
    private ICategoryFactory _factory;

    [SetUp]
    public void Init()
    {
      _factory = new FakeCategoryFactory();
      _repository = new FakeCategoryRepository(_factory);
    }

    [Test]
    public void Test_A_Category_Should_Have_An_Id_Greater_Than_Zero()
    {
      var category = _repository.FindById(101);
      Assert.IsTrue(category.Id > 0);
    }

    [Test]
    public void Test_I_Have_Got_10_Categories_In_My_Repository()
    {
      var categories = _repository.FindAll();
      Assert.AreEqual(10, categories.Count());
    }

    [Test]
    public void Test_A_Category_Needs_A_Name()
    {
      var category = _repository.FindById(101);
      Assert.IsTrue(category.Name.Length > 0);
    }
  }
}
